﻿using CSharpDay11.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Microsoft.AspNet.Identity;
using CSharpDay11.Adapters.Interfaces;
using CSharpDay11.Adapters.Adapters; //for User.Identity.GetUserId()
using Microsoft.AspNet.Identity.Owin;
using CSharpDay11.Models; //for GetUserManager<>()

namespace CSharpDay11.Controllers
{
    public class apiUserRoleController : ApiController
    {
        IUserAdapter _adapter;
       
        public apiUserRoleController()
        {
            _adapter = new UserAdapter();
        }
        public IHttpActionResult Get()
        {
            string UserId = User.Identity.GetUserId();
            ApplicationUserManager manager = Request.GetOwinContext().GetUserManager<ApplicationUserManager>();
            LoggedInUserViewModel model = _adapter.GetUser(UserId, manager);
            return Ok(model);
        }
    }
}
